//
//@File    :	8.2_firstref.cpp
//@Time    :	2021/08/14 19:57:15
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	defining and using a refernce
//

//引用变量
//含义:给变量起个别名,使其指向相同的值和内存单元
//用途:用作函数的形参,通过将引用变量用作参数,函数将使用原始数据而不是副本
// 必须在声明引用变量时进行初始化

#include <iostream>

using namespace std;

int main()
{
    int rats = 101;
    int &rodents = rats;
    cout << "rats = " << rats;
    cout << ", rodents = " << rodents << endl;
    rodents++;
    cout << "rats = " << rats;
    cout << ",rodents = " << rodents << endl;

    cout << "rats adress = " << &rats;
    cout << ",rodents daress = " << &rodents << endl;
    system("pause");
    return 0;
}